< previous page page_249 next page >

Page 249
The Me keyword refers to frmForm. In the clickedDoneBtn method, the code would be
Public Sub clickedDoneBtn(argForm As Form)
   Unload argForm
   Set argForm = Nothing
End Sub
The other methods of the FormOperations class aren't as straightforward. Standard processing for an OK button is dependent on the graphical user interface policy in place at your company. For individual or small projects, having such a policy, even in an informal setting, helps keep your approach to developing the GUI subsystem organized and thus easier to maintain.
Some projects implement the code for an OK button (cmdOK) in much the same way as the cmdDone button mentioned earlier. If that is the case in your environment, invoke the clickedDoneBtn in your OK buttons.
The Cancel and Undo buttons can be tricky. The Cancel button typically stops the process that the application is currently processing. The Undo button reverses the entry of information and subsequent transaction before the transaction is committed. Sometimes the Cancel button is meaningless because it does nothing or is used to hide or unload a form. At times, the name Cancel is ambiguous because it doesn't specifically indicate what is being canceled. Cancel buttons are more appropriate for small forms that have only a progress bar control indicating some process is underway that can be canceled. In most circumstances, however, what is typically called the Cancel button should instead be named Close.
Assuming you have a Transaction class with a class instance, theTransaction, your clickedCancelBtn method might look like the following:
Public Sub clickedCancelBtn()
  theTransaction.cancel
  Unload frmProgress
   Set frmProgress = Nothing
End Sub
The frmProgress object is a standard form for showing the progress of a transaction. It can have a ProgressBar control on it.
Tip
Often in today's programming environment, the Cancel button means either close the form or undo a transaction. With object-oriented programming, you need a clean separation of concerns. You can achieve this separation with two distinct buttons, Close and Undo Transaction. If you notice, you can clearly tell what a Close button does, as opposed to an Undo Transaction button. However, Cancel is too ambiguous.

 
< previous page page_249 next page >

If you like this book, buy it!